﻿using System;
using System.Windows.Forms;
using SQLDiagConfiguration.Properties;

namespace SQLDiagConfiguration
{
    /// <summary>
    /// This provides the Connection Info specifc implementations
    /// </summary>
    public partial class AuthenticationMethodPage : BasePage
    {
        #region Constructor
        public AuthenticationMethodPage(DiagInfoObject obj)
        {
            DiagInfo = obj;
            InitializeComponent();
        }
        #endregion Constructor
        public override void LoadControlText()
        {
            base.LoadControlText();
            lblMachineName.Text = Resources.strlblMachineName;
            lblInstanceName.Text = Resources.strlblInstanceName;
            gbAuthentication.Text = Resources.strgbAuthentication;
            rbWindowsAuth.Text = Resources.strrbWindowsAuth;
            rbSQLAuth.Text = Resources.strrbSQAuth;
            lblLoginName.Text = Resources.strlblLoginname;
        }

        #region Event Handlers
        /// <summary>
        /// This methods handles the enabling / disabling of appropriate elements
        /// based on the radio button selection
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void rbWindowsAuth_CheckedChanged(object sender, EventArgs e)
        {
            RadioButton pressed = (RadioButton)sender;
            bool bSQLLogin =true;
            if(pressed.Name == Resources.strrbWindowsAuth && pressed.Checked == true)
                bSQLLogin = false;
            if (!bSQLLogin)
            {
                txtSQLLogin.Text = Resources.strEmptyString;
            }
            txtSQLLogin.Enabled = bSQLLogin;
            txtSQLLogin.ReadOnly = !bSQLLogin;
        }
        #endregion Event Handlers
    }
}
